package com.csist.service.po.basicInfoModule.impl;

import com.csist.mapper.po.basicInfoModule.LevelMajorInfoMapper;
import com.csist.pojo.po.basicInfoModule.LevelMajorInfo;
import com.csist.service.bo.impl.LevelRegistrationBoServiceImpl;
import com.csist.service.po.basicInfoModule.LevelMajorInfoService;
import com.csist.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.Collections;
import java.util.List;

/**
 * @ClassName LevelMajorInfoServiceImpl
 * @Description 【自行描述】
 * @Author cn
 * @Date 2024/6/27 12:48
 * @Version 1.0
 */
public class LevelMajorInfoServiceImpl implements LevelMajorInfoService {
    private SqlSession sqlSession;
    private LevelMajorInfoMapper levelMajorInfoMapper;

    public LevelMajorInfoServiceImpl() {
        sqlSession = SqlSessionUtil.openSession();
        levelMajorInfoMapper = sqlSession.getMapper(LevelMajorInfoMapper.class);
    }

    @Override
    public List<LevelMajorInfo> findAll() {
        List<LevelMajorInfo> list = levelMajorInfoMapper.findAll();
        if (list != null && list.size() > 0) {
            return list;
        }
        return null;
    }

    @Override
    public LevelMajorInfo getLevelMajorInfoById(int id) {
        LevelMajorInfo levelMajorInfoById = levelMajorInfoMapper.getLevelMajorInfoById(id);
        if (levelMajorInfoById != null) {
            return levelMajorInfoById;
        }
        return null;
    }

    @Override
    public List<LevelMajorInfo> findLevelMajorInfoFuzzy(LevelMajorInfo levelMajorInfo) {
        List<LevelMajorInfo> list = levelMajorInfoMapper.findLevelMajorInfoFuzzy(levelMajorInfo);
        if (list != null && list.size() > 0) {
            return list;
        }
        return null;
    }

    @Override
    public List<LevelMajorInfo> findLevelMajorInfo(LevelMajorInfo levelMajorInfo) {
        List<LevelMajorInfo> list = levelMajorInfoMapper.findLevelMajorInfo(levelMajorInfo);
        if (list != null && list.size() > 0) {
            return list;
        }
        return null;
    }

    @Override
    public int addLevelMajorInfo(LevelMajorInfo levelMajorInfo) {
        int i = levelMajorInfoMapper.addLevelMajorInfo(levelMajorInfo);
        if (i > 0) {
            sqlSession.commit();
            return i;
        }
        return 0;
    }

    @Override
    public int updateLevelMajorInfo(LevelMajorInfo levelMajorInfo) {
        int i = levelMajorInfoMapper.updateLevelMajorInfo(levelMajorInfo);
        if (i > 0) {
            sqlSession.commit();
            return i;
        }
        return 0;
    }

    @Override
    public int updateLevelMajorInfoByState(int lmiId) {
        int i = levelMajorInfoMapper.updateLevelMajorInfoByState(lmiId);
        if (i > 0) {
            sqlSession.commit();
            return i;
        }
        return 0;
    }

    @Override
    public int deleteLevelMajorInfo(int lmiId) {
        return 0;
    }
}
